import { PageForm } from '#/entity';

type ChangeFunctionType = (page: number, rows: number) => void;

export interface PaginationProps {
  page: PageForm;
  onPageChange: ChangeFunctionType;
  count: number;
}

export function pagination({ page, onPageChange, count }: PaginationProps) {
  return {
    current: page.page,
    pageSize: page.take,
    pageSizeOptions: [5, 10, 20, 50],
    defaultPageSize: 10,
    total: count,
    showQuickJumper: true,
    showSizeChanger: true,
    showTotal: (total: number) => {
      return `共 ${total} 条`;
    },
    onChange: (page: number, rows: number) => {
      onPageChange(page, rows);
    },
  };
}
